package com.googlecode.spruce.dao.impl;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.googlecode.spruce.dao.AbstractDao;
import com.googlecode.spruce.dao.ServiceDao;
import com.googlecode.spruce.domain.Service;

@Repository
@Transactional
public class DefaultServiceDao extends AbstractDao<Integer, Service> implements ServiceDao
{

    public DefaultServiceDao()
    {
        super(Service.class);
    }

    @Override
    public Service findByName(final String serviceCheck)
    {
        final Query query = super.getSession().createQuery("from Service where pluginName = :name");
        query.setParameter("name", serviceCheck);
        return (Service) query.list().get(0);
    }
}
